import requests
from bs4 import BeautifulSoup
import re
import time


def get_content():
    proxies = {
        "http": "http://183.247.211.41:30001",
        "https": "https://121.8.146.99:8060",
    }

    while True:
        url = 'http://www.cntour.cn/'
        strhtml = requests.get(url, proxies=proxies)
        soup = BeautifulSoup(strhtml.text, 'lxml')

        data = soup.select('#main>div>div.mtop.firstMod.clearfix>div.centerBox>ul.newsList>li>a')
        print(data, end="\n\n")

        for item in data:
            result = {
                'title': item.get_text(),
                'link': item.get('href'),
                'ID': re.findall('\d+', item.get('href'))[0]
            }
            print(result)

        # 缓2s
        time.sleep(2)


if __name__ == '__main__':
    get_content()
